﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WFCSharp_I
{
    public partial class MDIForm : Form
    {
        public MDIForm()
        {
            InitializeComponent();
        }

        private void openButton_Click(object sender, EventArgs e)
        {
            OrderFood orderForm = new OrderFood();
            orderForm.MdiParent = this;
            orderForm.Show(); // -> hiển thị cửa sổ ở dạng Modeless

            Signup signForm = new Signup();
            signForm.MdiParent = this;
            signForm.Show(); // -> hiển thị cửa sổ ở dạng Modeless

            WordPad wordPad = new WordPad();
            wordPad.MdiParent = this;
            wordPad.Show(); // -> hiển thị cửa sổ ở dạng Modeless

            //orderForm.ShowDialog(); // -> hiển thị cửa sổ ở dạng Modal
        }

        private void childrenButton_Click(object sender, EventArgs e)
        {
            string listForm = "Children : \r\n";
            foreach (Form i in this.MdiChildren)
                // for (int j = 0; j < this.MdiChildren.Length; j++)
                //      i = this.MdiChildren[j];
                listForm += i.Text + "\r\n";

            listForm += "Actived : " + this.ActiveMdiChild.Text;
            MessageBox.Show(listForm);
        }

        private void layoutCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (layoutCombo.SelectedIndex == 0)
                this.LayoutMdi(MdiLayout.ArrangeIcons);
            else if (layoutCombo.SelectedIndex == 1)
                this.LayoutMdi(MdiLayout.Cascade);
            else if (layoutCombo.SelectedIndex == 2)
                this.LayoutMdi(MdiLayout.TileHorizontal);
            else if (layoutCombo.SelectedIndex == 3)
                this.LayoutMdi(MdiLayout.TileVertical);
        }

        private void subversionProjectItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Subversion Project here!");
        }

        private void buildComboMenuItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            MessageBox.Show(buildComboMenuItem.SelectedItem.ToString());
        }

        private void cascadeMenuItem_Click(object sender, EventArgs e)
        {
            timer.Start();
            toolStripProgressBar.Visible = true;
        }

        private void tileHozirationMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void tileVerticalMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.TileVertical);
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            toolStripProgressBar.Increment(20);

            if (toolStripProgressBar.Value == toolStripProgressBar.Maximum)
            {
                timer.Stop();
                this.LayoutMdi(MdiLayout.Cascade);
            }
        }
    }
}
